package com.sl.au.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.sl.au.entity.Account;
import com.sl.au.entity.EXDEPayBackTypeArea;
import com.sl.au.service.EXDEPayAnalyzeAreaService;


/**
 * 片区回款类型分析控制器控制层
 * zty
 * 2017-02-20
 */
@RestController
@RequestMapping(value="/ui/analyzeArea")
public class PayAnalyzeAreaController extends BaseController{
	
	@Autowired
	EXDEPayAnalyzeAreaService exdePayAnalyzeAreaService;
	
    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView index(){
        ModelAndView modelAndView=createLayoutView("payment/analyzeArea");
        Account a = this.getMyAccount();
		String userId =a.getUser().getId();
		modelAndView.addObject("userId",userId);
		return modelAndView;
    }
    
    /*
     * 
     */
    @RequestMapping(value = "/getMyTrance", method = RequestMethod.POST)
	public Map<String,Object> getMyTrance(HttpServletRequest request) {
		Map<String,Object> map = new HashMap<String,Object>();
		Map<String,String> condition = new HashMap<String,String>();
		Account a = this.getMyAccount();
		int start = Integer.parseInt(request.getParameter("start"));
		int length = Integer.parseInt(request.getParameter("length"));
		String superior = a.getUser().getSaleArea().getSuperior();//获取部门信息
		//String sSuperior = "成套处";
		String beginPaidDate = request.getParameter("beginPaidDate");//开始年月
		String endPaidDate = request.getParameter("endPaidDate");//结束时间	
		condition.put("sSuperior", superior);
	    condition.put("beginPaidDate", beginPaidDate);
	    condition.put("endPaidDate", endPaidDate);
		List<EXDEPayBackTypeArea> users = null;
		users = exdePayAnalyzeAreaService.getMyPage(beginPaidDate,endPaidDate,superior);
        long count = users.size();
		map.put("data", users);
		map.put("draw", request.getParameter("draw"));
		map.put("recordsFiltered", count);
		map.put("recordsTotal", count);
		return map;
	}
}
